package heima3_2.cn.osc.hold;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.squareup.picasso.Picasso;

import net.oschina.app.R;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import de.hdodenhof.circleimageview.CircleImageView;
import heima3_2.cn.osc.base.BaseHolder;
import heima3_2.cn.osc.base.MyBaseAdapter;
import heima3_2.cn.osc.model.bean.ActiveBean;
import heima3_2.cn.osc.utils.Global;

/**
 * Created by yaozhanlie on 2017/1/13.
 */

public class CallMeHolder extends BaseHolder<ActiveBean> {


    @Bind(R.id.civ_msg_photo)
    CircleImageView mCivMsgPhoto;
    @Bind(R.id.tv_msg_name)
    TextView mTvMsgName;
    @Bind(R.id.tv_msg_dynamic)
    TextView mTvMsgDynamic;
    @Bind(R.id.tv_msg_content)
    TextView mTvMsgContent;
    @Bind(R.id.tv_msg_mobile)
    TextView mTvMsgMobile;
    @Bind(R.id.tv_msg_time)
    TextView mTvMsgTime;
    @Bind(R.id.call_me_item)
    RelativeLayout mCallMeItem;

    public CallMeHolder(Context context, ViewGroup parent, MyBaseAdapter<ActiveBean> adapter, int position, ActiveBean bean) {
        super(context, parent, adapter, position, bean);
    }

    @Override
    public View onCreateView(Context context, ViewGroup parent, int position, ActiveBean bean) {
        View view = Global.inflats(R.layout.item_msg_atme);
        ButterKnife.bind(this, view);
//        mTvMsgName = (TextView) view.findViewById(R.id.tv_msg_name);
//        mTvMsgContent = (TextView) view.findViewById(R.id.tv_msg_content);
//        mTvMsgTime = (TextView) view.findViewById(R.id.tv_msg_time);
//        mCivMsgPhoto = (CircleImageView) view.findViewById(R.id.civ_msg_photo);
        return view;
    }

    @Override
    protected void onRefreshView(ActiveBean bean, int position) {
        mTvMsgName.setText(bean.getAuthor());
        mTvMsgContent.setText(bean.getMessage());
        mTvMsgTime.setText(bean.getPubDate());
        Picasso.with(context).load(bean.getPortrait()).resize(50, 50).centerCrop().into(mCivMsgPhoto);
    }

    @OnClick({R.id.civ_msg_photo, R.id.call_me_item})
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.civ_msg_photo:
                Toast.makeText(context, "进入用户中心", Toast.LENGTH_SHORT).show();
                break;
            case R.id.call_me_item:
                Toast.makeText(context, "进入动弹详情", Toast.LENGTH_SHORT).show();
                break;
        }
    }
}


